<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<title>修改密码</title>
<head th:replace="common/incHead :: incHead"></head>
<body class="gray-bg">
<div class="ok-body">
    <form class="layui-form layui-form-pane" lay-filter="FormPasswordChange">
        <div class="layui-row p-l-sm m-b-xl">
            <div class="layui-row">
                <div th:replace="common/plugin :: pa-form-input('password','旧密码(*)','oldPass','layui-col-md4',32,'required','')"></div>
            </div>
            <div class="layui-row">
                <div th:replace="common/plugin :: pa-form-input('password','新密码(*)','newPass','layui-col-md4',32,'required','')"></div>
            </div>
            <div class="layui-row m-t">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button id="btnEditSubmit" class="layui-btn layui-btn-normal">立即修改</button>
                        <button type="reset" class="layui-btn layui-btn-primary">&nbsp;&nbsp;&nbsp;&nbsp;重置&nbsp;&nbsp;&nbsp;&nbsp;</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div th:replace="common/incBottom :: incBottom"></div>
<script th:inline="none">
    layui.use(["jquery", 'form', "okLayer", "okPapper"], function () {
        let form = layui.form;
        let okLayer = layui.okLayer;
        let $ = layui.jquery;
        form.render();
        $("#btnEditSubmit").on("click", function () {
            let stop = form.doVerify("FormPasswordChange");
            if (!stop) {
                return false;
            }
            let subFormData = form.val("FormPasswordChange");
            $.ajax({
                type: 'POST', url: "/password/change", data: subFormData, dataType: "json", cache: false, success: function (data) {
                    if (data.statusCode == '200') {
                        okLayer.sweetSuccess("密码修改成功", data.message, function () {
                        });
                    } else {
                        okLayer.sweetError("密码修改失败", data.message);
                    }
                }, error: function (xhr) {
                    okLayer.sweetError("请求数据异常:" + xhr.status, xhr.responseText);
                }
            });
            return false;
        });
        okLoading.close($);
    })
</script>
</body>
</html>